package com.example.sxt_practise.thread.auxiliarytools;

import java.util.concurrent.CountDownLatch;

/**
 * 计数器(减法)
 * @author gaofeng
 * @date 2022年06月04日 13:42
 */
public class CountDownLaunchTest {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch count = new CountDownLatch(6) ;

        for (int i = 0; i < 6; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + " GO OUT");
                // 计数器减一
                count.countDown();
            }, String.valueOf(i)).start();
        }

        count.await();

        System.out.println("全都出去了");
    }
}
